package com.appservice.controller;

import com.vidyu.businesslayer.businessentities.Employer;
import com.vidyu.businesslayer.businessentities.Msg;
import com.vidyu.servicelayer.servicedataentitties.EmployerRO;
import com.vidyu.servicelayer.servicedataentitties.MsgRO;
import com.vidyu.servicelayer.servicedataentitties.ProjectRO;
import com.vidyu.servicelayer.servicedataentitties.TestRO;
import com.vidyu.servicelayer.serviceinterface.ControllerServiceWrapper;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * Created by IntelliJ IDEA.
 * Session: eyalsa
 * Date: 06/03/12
 * Time: 16:11
 * Link Users To Agency
 */
@Controller
public class MsgController {

    private static final Logger logger = Logger.getLogger(MsgController.class);

    @Autowired
    ControllerServiceWrapper controllerServiceWrapperImpl;

    @RequestMapping(value = "/vidyu/msg/create",method = RequestMethod.POST)
    public @ResponseBody
    long addMsg(@RequestBody MsgRO msgRO) throws Exception{
        try {
            return controllerServiceWrapperImpl.addMsg(msgRO);
        } catch (Exception e) {
            logger.fatal(e);
            throw e;
        }
    }

    @RequestMapping(value = "/vidyu/msg/update",method = RequestMethod.POST)
    public @ResponseBody
    void updateMsgStatus(@RequestBody MsgRO msgRO) throws Exception{
        try {
            controllerServiceWrapperImpl.updateMsgStatus(msgRO);
        } catch (Exception e) {
            logger.fatal(e);
            throw e;
        }
    }

    @RequestMapping(value = "/vidyu/msg/getMsgInbox/{fromId}", method= RequestMethod.GET)
    public
    @ResponseBody
    List<Msg> getMsgInbox(@PathVariable long fromId) throws Exception {
        try {
            return controllerServiceWrapperImpl.getMsgInbox(fromId);
        } catch (Exception e) {
            logger.fatal(e);
            throw e;
        }
    }

}

